{# vim: set et ts=8 sts=4 sw=4 ai: #}
{% extends "form.html" %}
{% block menu %}
{{ super() }}
{% include 'snippets/menutree.html' %}
{% endblock %}
{% block formcontent %}
{% if olddrafts or newdrafts %}
{% set temp = namespace(ownold=false, ownnew=false, others=false) %}
    <div class="invalid-feedback">
{% if olddrafts %}
        There are drafts saved for <strong>{{pagename}}</strong>:
      <ul class="mt-10">
{% for draft in olddrafts -%}
<li>
{%if current_user.email == draft.author_email%}
    Your draft
{% set temp.ownold = True %}
{%else%}
    {{draft.author_email}}'s draft
{% set temp.others = True %}
{%endif%}
 last updated on <span title="{{draft.datetime|format_datetime("deltanow")}} ago">{{draft.datetime|format_datetime}}</span></li>
{% endfor -%}
      </ul>
{%endif%}
{% if newdrafts %}
        There are drafts saved for <strong>{{new_pagename}}</strong>:
      <ul class="mt-10">
{% for draft in newdrafts -%}
<li>
{%if current_user.email == draft.author_email%}
    Your draft
{% set temp.ownnew = True %}
{%else%}
    {{draft.author_email}}'s draft
{% set temp.others = True %}
{%endif%}
 last updated on <span title="{{draft.datetime|format_datetime("deltanow")}} ago">{{draft.datetime|format_datetime}}</span></li>
{% endfor -%}
      </ul>
{%endif%}
      {% if temp.ownnew or temp.ownold %}
      You can review and edit or discard your draft{%if temp.ownold and temp.ownnew %}s {%endif%}
      {%if temp.ownold%} for <strong>{{pagepath}}</strong> <a class="hyperlink-underline text-danger" href="{{ url_for("edit", path=pagepath) }}">here</a>{%endif%}
      {%- if temp.ownold and temp.ownnew %} and {%endif%}
      {%- if temp.ownnew%} <strong>{{new_pagename}}</strong> <a class="hyperlink-underline text-danger" href="{{ url_for("edit", path=new_pagename) }}">here</a>{%endif%}.
      {% endif %}
      {% if temp.others %}
      You can not review, edit or discard the drafts of other users. They will persist for the current pagename.
      {% endif %}
    </div>
{% endif %}
<form action="{{ url_for("rename", path=pagepath) }}" method="POST" class="form-inline">
  <div class="form-group">
    <label for="new_pagename" class="required w-150">New name</label>
    <input type="text" class="form-control" name="new_pagename" id="new_pagename" value="{{new_pagename if new_pagename else pagename}}" placeholder="{{pagename}}" autofocus="" onfocus="this.setSelectionRange(this.value.length,this.value.length);">
  </div>
  <div class="form-group">
    <label for="message" class="w-150">Commit message</label>
    <input type="text" class="form-control" name="message" id="message" placeholder="Renamed {{pagename}} to {{new_pagename if new_pagename else "..."}}" value="{{ message if message }}">
  </div>
  {% if pagename_prefixes and pagename_prefixes|length > 0  %}
  <div class="form-group mb-5">
    <div class="w-100 mr-10">
    Move page in subdirectory:
    </div>
    <div style="position: relative; -ms-flex: 1 1 0%; flex: 1 1 0%; min-width: 0;">
    {% for prefix in pagename_prefixes %}
    <button type="button" class="btn btn-xsm mb-5 mr-5" onclick="return otterwiki.toggle_pagename_prefix('new_pagename','{{prefix}}')">{{prefix}}/</button>
    {% endfor %}
    </div>
  </div>
  {% endif %}
  <div class="form-group">
    <div class="form-text text-wrap">
        Hint: Avoid abbreviations. Try to limit your name to three simple words or fewer.
    </div>
  </div>
  <input class="btn btn-primary" type="submit" value="Rename">
  <a href="{{ url_for("view", path=pagepath) }}" class="btn" role="button">Cancel</a>
</form>
{% endblock %}
